<?php
	session_start();
	include_once "../classes/thuvienham.php";
	if(!IsAdmin() && !IsBTV())
		header("Location: index.php");
	include_once "../classes/baiviet_bs.php";
	$baiviet = new baiviet_bs();
	
	if(isset($_SESSION['DangNhap']) && $_SESSION['MaLoaiNguoiDung'] == 1)
	{
		$baiviet->SetMaBaiViet($_GET['mabaiviet']);
		$data_bv = $baiviet->LayDanhSach();
		if($data_bv[0]['PIN'] = $_GET['pin'])
		{
			$baiviet->SetMaBaiViet($_GET['mabaiviet']);
			$data_baiviet = $baiviet->LayDanhSach();
			$image = $data_baiviet[0]['HinhAnh'];
			
			//Xóa bỏ hình ảnh trong bài viết
			unlink("../" . $image);
			$result = $baiviet->Xoa();
			
			header('Location: ' . $_SERVER['HTTP_REFERER']);
		}
	}
?>